#include <iostream>
#include <string>
#include <sstream>

/**
 * 最长最短单词
 */
int main() {
	std::string str;
	std::getline(std::cin, str);

	std::stringstream ss(str);

	std::string longestWord;
	int longestCnt = 0;

	std::string shortestWord;
	int shortestCnt = 110;

	std::string word;
	while (ss >> word) {
		int length = word.length();
		if (length > longestCnt) {
			longestWord = word;
			longestCnt = length;
		}
		if (length < shortestCnt) {
			shortestWord = word;
			shortestCnt = length;
		}
	}

	std::cout << longestWord << "\n" << shortestWord;


	return 0;
}